﻿using System;
using System.Collections.Generic;
using CPETwit.WPFClient.Business.AuthentificationServiceReference;
using CPETwit.WPFClient.Business.TwitterServiceReference;
using CPETwit.WPFClient;

namespace CPETwit.WPFClient.Business.Service
{
    public class WCFServiceCaller
    {
        private readonly TwitterServiceClient _twitterService;
        private readonly AuthentificationServiceClient _authentificationService;

        public WCFServiceCaller()
        {
            _twitterService = new TwitterServiceClient();
            _authentificationService = new AuthentificationServiceClient();
        }

        public IEnumerable<Tweet> GetUserTimeline(User user)
        {
            return _twitterService.GetUserTimeline(user);
        }

        public IEnumerable<Tweet> GetUserTweets(User user)
        {
            return _twitterService.GetAllTweetsByUserId(user.id);            
        } 

        public User GetUserByLogin(string login)
        {
            return _twitterService.GetUser(login);
        }

        public IEnumerable<User> GetUsersByText(string text)
        {
            return _twitterService.GetUsersByText(text);
        }

        public void UpdateUser(User user)
        {
            _twitterService.UpdateUser(user);
        }

        public void Follow(User follower, User publisher)
        {
            _twitterService.Follow(follower, publisher);
        }


        public void UnFollow(User follower, User publisher)
        {
            _twitterService.Unfollow(follower, publisher);
        }

        public bool CheckLoginAndPassword(string userName, string password)
        {
            return _authentificationService.CheckLoginAndPassword(userName, password);
        }

        public void CreateMessage(string message, User user, bool tweetOnTwitter)
        {
            _twitterService.SaveTweet(user, message, tweetOnTwitter);
        }

        public void RegisterUser(string userName, string password, string email)
        {
            _twitterService.CreateUser(userName, password, email);
        }

        public bool IsEmailValid(string email)
        {
            return _twitterService.IsEmailValid(email);
        }

        public bool IsUserNameValid(string email)
        {
            return _twitterService.IsUserNameValid(email);
        }

        public void ReTweet(User user, Tweet tweet, bool tweetOnTwitter)
        {
            _twitterService.ReTweet(user, tweet, tweetOnTwitter);
        }
        public void UndoReTweet(User user, Tweet tweet)
        {
            _twitterService.UndoReTweet(user, tweet);
        }

        public IEnumerable<Tweet> GetTweetsByResearch(string research)
        {
           return  _twitterService.GetAllTweetsByText(research);
        }

        public IEnumerable<Tweet> GetTweetsByTag(string search)
        {
            return _twitterService.GetAllTweetsByTag(search);
        }
    }
}
